<%@ Page Language="c#" AutoEventWireup="true" MasterPageFile="~/MasterPages/Main.Master" CodeFile="Login.aspx.cs" Inherits="_Login" Title="Login" %>

<asp:Content ID="Main" ContentPlaceHolderID="body" runat="server">
	<asp:Panel ID="loginDetail" Width="100%" runat="server">
		<fieldset>
			<legend>Login Detail</legend>
			<asp:GridView ID="loginGrid" AllowPaging="True" AllowSorting="True" BorderColor="White"
				BorderStyle="Ridge" CellSpacing="0" CellPadding="3" BackColor="#ffffff" AutoGenerateColumns="false"
				DataSourceID="loginSource" runat="server" Width="100%" EnableSortingAndPagingCallbacks="True">
				<HeaderStyle BackColor="#ffffff" HorizontalAlign="left" Font-Bold="true" />
				<AlternatingRowStyle BackColor="#CCCC99" />
				<PagerSettings Mode="NumericFirstLast" Position="Bottom" />
				<Columns>
					<asp:HyperLinkField HeaderText="ID" DataTextField="Id" SortExpression="Id" DataNavigateUrlFields="Id"
					DataNavigateUrlFormatString="~/SampleForms/Login.aspx?LoginId={0}" Target="_parent" />
					<asp:BoundField HeaderText="Active" DataField="Active" SortExpression="Active" />
					<asp:BoundField HeaderText="Email" DataField="Email" SortExpression="Email" />
					<asp:BoundField HeaderText="FirstName" DataField="FirstName" SortExpression="FirstName" />
					<asp:BoundField HeaderText="LastName" DataField="LastName" SortExpression="LastName" />
					<asp:BoundField HeaderText="UserName" DataField="UserName" SortExpression="UserName" />
					<asp:BoundField HeaderText="Password" DataField="Password" SortExpression="Password" />
					<asp:BoundField HeaderText="PasswordQuestion" DataField="PasswordQuestion" SortExpression="PasswordQuestion" />
					<asp:BoundField HeaderText="PasswordAnswer" DataField="PasswordAnswer" SortExpression="PasswordAnswer" />
				</Columns>
			</asp:GridView>		
		</fieldset>
	</asp:Panel>
    <asp:FormView ID="loginView" DataSourceID="loginDetailSource" DataKeyNames="Id"
	    OnModeChange="loginView_ModeChanged" Width="100%" runat="server">
        <ItemTemplate>
			 <fieldset>
				<legend>Login Detail</legend>
				<ol>
				<li>
				<asp:Label ID="idLabel" Text="Id" runat="server"/>
				<asp:Label ID="id" Text='<%# Eval("Id") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="activeLabel" Text='Active' runat="server"/>
				<asp:CheckBox id="active" Checked='<%# Eval("Active") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="emailLabel" Text='Email' runat="server"/>
				<asp:Label ID="email" Text='<%# Eval("Email") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="firstNameLabel" Text='FirstName' runat="server"/>
				<asp:Label ID="firstName" Text='<%# Eval("FirstName") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="lastNameLabel" Text='LastName' runat="server"/>
				<asp:Label ID="lastName" Text='<%# Eval("LastName") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="userNameLabel" Text='UserName' runat="server"/>
				<asp:Label ID="userName" Text='<%# Eval("UserName") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="passwordLabel" Text='Password' runat="server"/>
				<asp:Label ID="password" Text='<%# Eval("Password") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="passwordQuestionLabel" Text='PasswordQuestion' runat="server"/>
				<asp:Label ID="passwordQuestion" Text='<%# Eval("PasswordQuestion") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="passwordAnswerLabel" Text='PasswordAnswer' runat="server"/>
				<asp:Label ID="passwordAnswer" Text='<%# Eval("PasswordAnswer") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
			    </ol>
			 </fieldset>
			 <asp:Button ID="add" CommandName="New" Text="Add" runat="server" />
			 <asp:Button ID="edit" CommandName="Edit" Text="Edit" runat="server" />
			 <asp:Button ID="delete" CommandName="Delete" Text="Delete" runat="server" />
		</ItemTemplate>
		<InsertItemTemplate>
			 <fieldset>
				<legend>New Login Detail</legend>
				<ol>
				<li>
				<asp:Label ID="activeLabel" Text='Active' runat="server"/>
				<asp:CheckBox id="active" Checked='<%# Bind("Active") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="emailLabel" Text='Email' runat="server"/><br/>
				<asp:TextBox id="email" Text='<%# Bind("Email") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="firstNameLabel" Text='FirstName' runat="server"/><br/>
				<asp:TextBox id="firstName" Text='<%# Bind("FirstName") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="lastNameLabel" Text='LastName' runat="server"/><br/>
				<asp:TextBox id="lastName" Text='<%# Bind("LastName") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="userNameLabel" Text='UserName' runat="server"/><br/>
				<asp:TextBox id="userName" Text='<%# Bind("UserName") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="userName_RequiredFieldValidator" ControlToValidate="userName" Text="*" ErrorMessage="'UserName' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="passwordLabel" Text='Password' runat="server"/><br/>
				<asp:TextBox id="password" Text='<%# Bind("Password") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="password_RequiredFieldValidator" ControlToValidate="password" Text="*" ErrorMessage="'Password' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="passwordQuestionLabel" Text='PasswordQuestion' runat="server"/><br/>
				<asp:TextBox id="passwordQuestion" Text='<%# Bind("PasswordQuestion") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="passwordAnswerLabel" Text='PasswordAnswer' runat="server"/><br/>
				<asp:TextBox id="passwordAnswer" Text='<%# Bind("PasswordAnswer") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<!-- TODO: Implement Many to Many (Roles) -->
				</ol>
			 </fieldset>
             <asp:Button ID="submit" CommandName="Insert" Text="Save" runat="server" />
        </InsertItemTemplate>
		<EditItemTemplate>
			<fieldset>
				<legend>Edit Login Detail</legend>
				<ol>
				<li>
				<asp:Label ID="idLabel" Text="Id" runat="server"/>
				<asp:Label Id="id" Text='<%# Bind("Id") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="activeLabel" Text='Active' runat="server"/>
				<asp:CheckBox id="active" Checked='<%# Bind("Active") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="emailLabel" Text='Email' runat="server"/><br/>
				<asp:TextBox id="email" Text='<%# Bind("Email") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="firstNameLabel" Text='FirstName' runat="server"/><br/>
				<asp:TextBox id="firstName" Text='<%# Bind("FirstName") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="lastNameLabel" Text='LastName' runat="server"/><br/>
				<asp:TextBox id="lastName" Text='<%# Bind("LastName") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="userNameLabel" Text='UserName' runat="server"/><br/>
				<asp:TextBox id="userName" Text='<%# Bind("UserName") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="userName_RequiredFieldValidator" ControlToValidate="userName" Text="*" ErrorMessage="'UserName' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="passwordLabel" Text='Password' runat="server"/><br/>
				<asp:TextBox id="password" Text='<%# Bind("Password") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="password_RequiredFieldValidator" ControlToValidate="password" Text="*" ErrorMessage="'Password' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="passwordQuestionLabel" Text='PasswordQuestion' runat="server"/><br/>
				<asp:TextBox id="passwordQuestion" Text='<%# Bind("PasswordQuestion") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="passwordAnswerLabel" Text='PasswordAnswer' runat="server"/><br/>
				<asp:TextBox id="passwordAnswer" Text='<%# Bind("PasswordAnswer") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<!-- TODO: Implement Many to Many (Roles) -->
				</ol>
			 </fieldset>
             <asp:Button ID="submit" CommandName="Update" Text="Save" runat="server" />
        </EditItemTemplate>
		<EmptyDataTemplate>
				<fieldset>
				<legend>Login Detail</legend>
				No Record Selected
				</fieldset>
			<asp:Button ID="add" CommandName="New" Text="Add" runat="server" />
		</EmptyDataTemplate>
    </asp:FormView>
	<asp:ObjectDataSource ID="loginSource" TypeName="Blog.Net.DataAccess.DataControls.LoginDataControl"
		DataObjectTypeName="Blog.Net.Business.BusinessObjects.LoginBO" SelectMethod="GetAll" SelectCountMethod="GetCountOfAll"
		InsertMethod="Save" UpdateMethod="Save" MaximumRowsParameterName="maxResults" StartRowIndexParameterName="firstResult"
		SortParameterName="sortExpression" EnablePaging="True" runat="server" >
		<InsertParameters>
            <asp:Parameter Name="login" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="login" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="loginDetailSource" SelectMethod="GetById" InsertMethod="Save" UpdateMethod="Save" DeleteMethod="Delete" DataObjectTypeName="Blog.Net.Business.BusinessObjects.LoginBO"
        TypeName="Blog.Net.DataAccess.DataControls.LoginDataControl" runat="server">
		<SelectParameters>
            <asp:QueryStringParameter Name="id" QueryStringField="LoginId" Type="Int32" />
        </SelectParameters>
		<InsertParameters>
            <asp:Parameter Name="login" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="login" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </UpdateParameters>
		<DeleteParameters>
            <asp:Parameter Name="login" Type="Object" />
        </DeleteParameters>
    </asp:ObjectDataSource>
	<asp:ObjectDataSource ID="roleSource" SelectMethod="GetAll" TypeName="Blog.Net.DataAccess.DataControls.RoleDataControl" runat="server"></asp:ObjectDataSource>
</asp:Content>